﻿#ifndef TK_THREAD_H
#define TK_THREAD_H

#include "tk_data_type.h"
#include "tk_mutex.h"
#include <QObject>
#include <QThread>

namespace tk
{

class TkThread : public QObject
{
    Q_OBJECT
public:
    explicit TkThread(QObject *parent = nullptr);
    ~TkThread();

    tk_bool Start(QThread::Priority priority = QThread::InheritPriority);
    tk_bool Exit();
	tk_bool IsRunning();
    QThread * GetThread();
    static tk_bool IsInterruptionRequested();

    static void SleepSec(tk_uint32 sec);
    static void SleepMs(tk_uint32 ms);
    static void SleepUs(tk_uint32 us);

signals:
    void SignalCallFunc();

private slots:
    void ThreadFunc();

signals:
    void SignalThreadRun();
private:
    QThread * m_pthread;
    TkMutex m_mutex;
};


}//namespace tk

#endif // TK_THREAD_H
